import {fileURLToPath, URL} from 'node:url'
import WindiCSS from 'vite-plugin-windicss'
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [vue(), WindiCSS(),],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    css: {
        // css预处理器
        preprocessorOptions: {
            scss: {
                // 预定义的变量
                additionalData: '@import "@/assets/style/mixin.scss";'
            }
        }
    },
    server: {
        // 代理
        proxy: {
            '/api': {
                target: 'http://127.0.0.1:5000',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ''),
            },
        }
    }
})
